package com.oa.organization.dao;

import java.util.List;

import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository;

import com.oa.organization.entity.Organization;

@Repository
public interface OrganizationDao extends CrudRepository<Organization, Long> {
	@Query("from Organization o where o.name = ?1")
	public Organization findByName(String name);

	@Query("from Organization o where o.parent.id = null")
	public List<Organization> findParentNode();

	@Query("from Organization o where o.parent.id = ?1")
	public List<Organization> findChildrenNodeById(Long parentId);
}
